package cn.wolfcode.shop.mapper;

import cn.wolfcode.shop.domain.Good;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * Created by wolfcode-lanxw
 */
@Mapper
public interface GoodMapper {
    @SelectProvider(type = GoodSelectProvider.class,method ="queryByIds")
    List<Good> queryByIds(@Param("ids") List ids);
    class GoodSelectProvider{
        public String queryByIds(@Param("ids") List ids){

            StringBuilder sql = new StringBuilder("select * from t_goods ");
            if(ids!=null && ids.size()>0){
                sql.append(" where id in (");
                for(int i=0;i<ids.size();i++){
                    if(i>0){
                        sql.append(",");
                    }
                    sql.append(ids.get(i));
                }
                sql.append(")");
            }
            return sql.toString();
        }
    }
}
